# -*- coding: utf-8 -*-
# @Time    : 2025/6/15 15:11
# @Author  : XinHuang
# @Email   : SA24231052@mail.ustc.edu.cn
# @File    : efficiency_memoize
# @Software: PyCharm
from efficiency import memoize
from time import perf_counter
import sys
from functools import lru_cache


def fibonacci_1(n: int) -> int:
    if n <= 2:
        return n
    else:
        return fibonacci_1(n - 1) + fibonacci_1(n - 2)


@memoize
def fibonacci_2(n: int) -> int:
    if n <= 2:
        return n
    else:
        return fibonacci_2(n - 1) + fibonacci_2(n - 2)

@lru_cache()
def fibonacci_3(n: int) -> int:
    if n <= 2:
        return n
    else:
        return fibonacci_2(n - 1) + fibonacci_2(n - 2)

if __name__ == '__main__':
    i = 20
    start = perf_counter()
    f_1 = fibonacci_1(i)
    end = perf_counter()
    print(f_1)
    print(f'Time: {end - start} seconds')
    start = perf_counter()
    f_2 = fibonacci_2(i)
    end = perf_counter()
    print(f_2)
    print(f'Time: {end - start} seconds')
    start = perf_counter()
    f_3 = fibonacci_3(i)
    end = perf_counter()
    print(f_3)
    print(f'Time: {end - start} seconds')
